/* ----------------------------------------------------------------------
*
* Copyright (C) 2024 XiaoFei. All rights reserved.
*
* @file:		XiaoZhi_LED.c
* @author:		XiaoFei
* @Date:     	24-April-2024
* @Revision: 	V1
* @Project: 	XiaoFei BSP Library
*
* -------------------------------------------------------------------- */

#include "stm32f10x.h"
#include "XiaoFei_Delay.h"
#include "XiaoZhi_LED.h"

/* 
* @function: 	GPIO_LED_Init
*/
void GPIO_LED_Init(void)				
{
    RCC_APB2PeriphClockCmd(RCC_GPIO_LED,ENABLE);		
	GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = LED_Pin;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(LED_GPIO, &GPIO_InitStructure);
}
	
/* 
* @function: 	LED_ON
*/
void LED_ON(void)
{
	GPIO_WriteBit(LED_GPIO,LED_Pin,LED_EN);
}

/* 
* @function: 	LED_OFF
*/
void LED_OFF(void)
{
	GPIO_WriteBit(LED_GPIO,LED_Pin,LED_NO);
}

/* 
* @function: 	LED_GLIMMER
* @parameter:	[in] ms					    The number of microseconds you want to delay.
*/
void LED_GLIMMER(int ms)
{
	GPIO_WriteBit(LED_GPIO,LED_Pin,Bit_RESET);
	XiaoFei_Delay_ms(ms);
	GPIO_WriteBit(LED_GPIO,LED_Pin,Bit_SET);
	XiaoFei_Delay_ms(ms);
}

/* 
* @function: 	LED_TURN
*/
void LED_TURN(void)
{
	if(GPIO_ReadOutputDataBit(LED_GPIO,LED_Pin)==0)
		GPIO_WriteBit(LED_GPIO,LED_Pin,Bit_SET);
	else GPIO_WriteBit(LED_GPIO,LED_Pin,Bit_RESET);
}
